package chapter10.practice23;

/**
 * Created by yangliwei on 2017/10/23.
 */
public class B{
    private U[]  u;

    public B(int length) {
        this.u = new U[length];
    }

    public void addU(U item,int i){
        u[i] = item ;
    }

    public void removeU(U item,int i){
        u[i] = null;
    }
    public void showU(){
        for(int i =0;i<u.length;i++){
            if(u[i]!=null){
                u[i].f1();
                u[i].f2();
                u[i].f3();
            }
        }
    }

    public static void main(String[] args) {
        B b = new B(3);
        A a = new A();
        b.addU(a.createU(),0);
        a = new A();
        b.addU(a.createU(),1);
        a = new A();
        b.addU(a.createU(),2);
        b.showU();
        b.removeU(a.createU(),2);
        System.out.println("after remove some item");
        b.showU();

    }
}

